package com.uneed.widget;

import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView;
import java.lang.ref.WeakReference;

import com.uneed.R;

public class HcListActivity extends HcActivity
{
  protected FrameLayout emptyView;
  private WeakReference<View> errorView;
  protected ListView listView;
  private WeakReference<View> loadingView;

  protected View createCategoryItem(String paramString)
  {
    View localView = getLayoutInflater().inflate(R.layout.category_item, this.listView, false);
    ((TextView)localView.findViewById(16908308)).setText(paramString);
    return localView;
  }

  protected View createEmptyItem()
  {
    View localView = new View(this);
    localView.setLayoutParams(new AbsListView.LayoutParams(-1, 24));
    return localView;
  }

  protected View getFailedView(String paramString, View.OnClickListener paramOnClickListener)
  {
    WeakReference<View> localWeakReference = this.errorView;
    View localView1;
	if (localWeakReference == null)
    {
        localView1 = getLayoutInflater().inflate(R.layout.error_item, this.emptyView, false);
        errorView = new WeakReference<View>(localView1);
        ((TextView)localView1.findViewById(16908308)).setText(paramString);
        Button btn_retry = (Button)localView1.findViewById(R.id.btn_retry);
        if (paramOnClickListener != null) {
      	  btn_retry.setVisibility(0);
      	  btn_retry.setOnClickListener(paramOnClickListener);
      	  btn_retry.requestFocus();
        }
    }   
    localView1 = (View)localWeakReference.get();
    return localView1;
  }

  protected View getLoadingView()
  {
    View localView = (View)loadingView.get();
    {
      if (localView == null)
      {
    	localView = getLayoutInflater().inflate(R.layout.loading_item, this.emptyView, false);
        loadingView = new WeakReference<View>(localView);
      }
    }
    return localView;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setupView();
    setEmptyView();
  }

  protected void setEmptyView()
  {
    this.listView = ((ListView)findViewById(R.id.list));
    this.emptyView = ((FrameLayout)findViewById(R.id.empty));
    this.listView.setEmptyView(this.emptyView);
  }

  protected void setupView()
  {
    setContentView(R.layout.list_frame);
  }
}
